package Test02;

import javax.swing.*;
import javax.swing.plaf.FontUIResource;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class DialogDemo extends JFrame {
     public DialogDemo() {

         setLayout(null);
         setBounds(300,300,300,300);
         setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
         //创建一个按钮
         JButton button = new JButton("弹窗");
         button.setBounds(100,200,150,60);
         add(button);
         //给按钮设置监听事件
         button.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
                 //写一个弹窗的窗口
                 new MyDialogDemo();
             }
         });
         setVisible(true);
     }
}
//弹窗的窗口
class MyDialogDemo extends JDialog{
    public MyDialogDemo() {
        this.setVisible(true);
        this.setBounds(200,100,500,500);
        //获得一个容器
        Container container = this.getContentPane();
        container.setLayout((null));
        JLabel label = new JLabel("测试");
        container.add(label);

    }
}